

import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/device/widgets/device_header.dart";
import "package:ct_pa_majordomo/widgets/normal_scaffold/index.dart";
import "package:flutter/material.dart";

class SelectRenter extends StatefulWidget {
  final Function(Map)? onchange;
  const SelectRenter({super.key, this.onchange});

  @override
  State<StatefulWidget> createState() => _SelectRenterState();

}

class _SelectRenterState extends State<SelectRenter> {
  @override
  Widget build(BuildContext context) {
    return NormalScaffold(
      title: "选择租客",
      child: Stack(
        children: [
          Positioned(
              width: MediaQuery.of(context).size.width,
              top: 0,
              left: 0,
              child: Container(
                  width: MediaQuery.of(context).size.width,
                  decoration: const BoxDecoration(
                    color: Colors.white,
                  ),
                  padding: const EdgeInsets.symmetric(horizontal: ThemeVars.paddingPage, vertical: 6),
                  child: const SizedBox(
                    height: 40,
                    child: TextField(
                      decoration: InputDecoration(
                        border: OutlineInputBorder(
                            borderRadius: BorderRadius.all(Radius.circular(5)),
                            borderSide: BorderSide.none
                        ),
                        hintText: "搜索租客姓名、电话、房源地址",
                        isDense: true,
                        filled: true,
                        fillColor: ThemeVars.colorBackground,
                        suffixIcon: SizedBox(
                          child: Icon(Icons.search, size: 20,),
                        ),
                      ),
                      style: TextStyle(fontSize: 14),
                    ),
                  )
              )
          ),
          Container(
            width: MediaQuery.of(context).size.width,
            margin: const EdgeInsets.only(top: 60, left: ThemeVars.paddingPage, right: ThemeVars.paddingPage),
            child: ListView(
              children: [
                GestureDetector(
                  behavior: HitTestBehavior.opaque,
                  onTap: () {
                    if (widget.onchange != null) {
                      widget.onchange!({"renterId": 256, "renterName": "张琳"});
                      Navigator.pop(context);
                    }
                  },
                  child: Container(
                    padding: EdgeInsets.all(ThemeVars.paddingPage),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                      color: Colors.white,
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text("小林-13023123132", style: TextStyle(fontWeight: FontWeight.w500, fontSize: 16),),
                        SizedBox(height: 8,),
                        Text("公寓A203", style: TextStyle(color: ThemeVars.colorTextTer, fontSize: 12),)
                      ],
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}